package org.andhy.formeasy.strategy;

import org.andhy.formeasy.core.ValidateItem;
import org.andhy.formeasy.valve.EnumValve;
import org.andhy.formeasy.valve.MaxLengthValve;
import org.andhy.formeasy.valve.MinLengthValve;
import org.andhy.formeasy.valve.MultipleValve;
import org.andhy.formeasy.valve.RegularValve;

import org.jdom.Element;


public class StringStrategy extends BaseStrategy {


	public ValidateItem build(Element paramElem) {
		vi.setPipeline(pipeline);
		vi.setName(paramElem.getAttributeValue("name"));
		if(paramElem == null ) return vi;
		
		Element multiple = paramElem.getChild(MultipleValve.IDENTIFY);
		if(null != multiple){
			pipeline.addValve(this.createMultipleValve(multiple));
		}
		
		pipeline.addValve(createEmptyValve(paramElem));
		
		
		Element maxElem = paramElem.getChild(MaxLengthValve.IDENTIFY);
		if(null != maxElem){
			pipeline.addValve(this.createMaxLengthValve(maxElem));
		}
		Element minElem = paramElem.getChild(MinLengthValve.IDENTIFY);
		if(null != minElem){
			pipeline.addValve(this.createMinLengthValve(minElem));
		}
		
		Element enumElem = paramElem.getChild(EnumValve.IDENTIFY);
		if(null != enumElem){
			pipeline.addValve(this.createMinValueValve(enumElem));
		}
		Element regElem = paramElem.getChild(RegularValve.IDENTIFY);
		if(null != regElem){
			pipeline.addValve(this.createMinValueValve(regElem));
		}
		return vi;
	}

	public String getName() {
		// TODO Auto-generated method stub
		return null;
	}

	public void setName(String name) {
		// TODO Auto-generated method stub
		
	}

}
